﻿using Furion.CMS.Core.Base;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.ComponentModel;

namespace Furion.CMS.Application
{
    public class LoginRecordSort : Core.Base.BaseSortParams
    {
        /// <summary>
        /// 时间
        /// </summary>
        public SortMode? LoginTime { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        public SortMode? Account { get; set; }
        /// <summary>
        /// 主机地址
        /// </summary>
        public SortMode? Host { get; set; }

        public override SortInfo GetSort()
        {
            // 默认按照登录时间进行排序
            SortInfo result = new SortInfo { Field = nameof(LoginTime), Mode = SortMode.Descend };
            if (LoginTime.HasValue)
            {
                result = new SortInfo { Field = nameof(LoginTime), Mode = LoginTime.Value };
            }
            else if (Account.HasValue)
            {
                result = new SortInfo { Field = nameof(Account), Mode = Account.Value };
            }
            else if (Host.HasValue)
            {
                result = new SortInfo { Field = nameof(Host), Mode = Host.Value };
            }
            return result;
        }
    }
}
